﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using EzDesk.DevHelper.EzMLGenerator.EzML;
using EzDesk.DevHelper.EzMLGenerator.EzMLanguageBuilder;

namespace EzDesk.DevHelper.EzMLGenerator
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string textSource = txtSource.Text;
            string sectionName = getSectionName();

            EzMLBuilder builder = new EzMLBuilder(textSource, sectionName);
            string textOutput = builder.Build();

            txtOutput.Text = textOutput;
            txtSource.Focus();
        }

        private string getSectionName()
        {
            string sectionName = "";
            if (radioBody.Checked)
            {
                sectionName = "body";
            }
            if (radioTitle.Checked)
            {
                sectionName = "title";
            }
            return sectionName;

        }

        private void button2_Click(object sender, EventArgs e)
        {
            string textSource = txtOutput.Text;
            string sectionName = getSectionName();

            EzMLLanguageBuilder builder = new EzMLLanguageBuilder(textSource, sectionName);
            string textOutput = builder.Build();

            textBox1.Text = textOutput;
            textBox1.Focus();  
        }


    }
}